import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtStrategy } from './jwt.strategy';
import { JwtHttpGuard } from './jwt-http.guard';
import { UnauthorizedFilter } from './unauthorized.filter';
import { UserModule } from '../user/user.module';
import { JwtRefreshInterceptor } from './jwt-refresh.interceptor';

@Module({
  imports: [
    PassportModule,
    JwtModule.register({
      secret: 'my_jwt_secret_key', // 在生产环境中应该使用环境变量
      signOptions: { expiresIn: '1h' },
    }),
    UserModule,
  ],
  controllers: [AuthController],
  providers: [AuthService, JwtStrategy, JwtHttpGuard, UnauthorizedFilter, JwtRefreshInterceptor],
  exports: [AuthService, JwtModule, JwtHttpGuard, JwtRefreshInterceptor],
})
export class AuthModule {}
